package com.test.controller;

import com.test.entity.UserBorrowView;
import com.test.service.BorrowService;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

@RestController
public class BorrowController {
    @Resource
    private BorrowService borrowService;
    @GetMapping("/borrow/{uid}")
    public UserBorrowView findUserBorrows(@PathVariable("uid") int uid) {
        //通过SecurityContextHolder将用户信息取出
        SecurityContext context = SecurityContextHolder.getContext();
        System.out.println(context.getAuthentication());
        return borrowService.getBorrowViewByUid(uid);
    }
}
